﻿using DataAccess;
using DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO
{
    public class QuanDAO
    {
        public static List<QuanDTO> LoadDanhSachQuan()
        {
            List<QuanDTO> list = new List<QuanDTO>();
            string sql = "SELECT * FROM QUAN";
            DataTable kq = DataConnection.ExecQuery(sql);
            if (kq.Rows.Count>0)
            {
                for (int i = 0; i < kq.Rows.Count; i++)
                {
                    DataRow dr = kq.Rows[i];
                    QuanDTO dd = new QuanDTO();
                    dd.MaQuan = Convert.ToInt64(dr["MaQuan"]);
                    dd.TenQuan = dr["TenQuan"].ToString();
                    list.Add(dd);  
                }
            }
            return list;
        }
        /*
        public static ArrayList loadDanhSachTheLoaiSach()
        {
            ArrayList ds = new ArrayList();

            string sql = "SELECT * FROM TheLoaiSach";
            DataTable kq = DataAccess.ExecQuery(sql);
            if (kq.Rows.Count > 0)
            {
                for (int i = 0; i < kq.Rows.Count; i++)
                {
                    DataRow dr = kq.Rows[i];
                    HeThongXuLy.TheLoaiSachDTO theLoaiSach = new HeThongXuLy.TheLoaiSachDTO();
                    theLoaiSach.MaTheLoaiSach = Convert.ToInt32(dr["MaTheLoaiSach"]);
                    theLoaiSach.TenTheLoaiSach = dr["TenTheLoaiSach"].ToString();
                    ds.Add(theLoaiSach);
                }
            }

            return ds;
        }
         * */
        public static DataTable DanhSachQuan()
        {
            string query = "SELECT * FROM QUAN";
            DataTable dt = DataConnection.ExecQuery(query);
            return dt;
        }
      
    }
}
